package com.muyu.danmo.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoFamousPicture;
import com.muyu.danmo.service.IDanmoFamousPictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 名帖字库图片Controller
 *
 * @author yangle
 * @date 2024-09-23
 */
@RestController
@RequestMapping("/picture")
public class DanmoFamousPictureController extends BaseController
{
    @Autowired
    private IDanmoFamousPictureService danmoFamousPictureService;

    /**
     * 查询名帖字库图片列表
     */
//    @RequiresPermissions("system:picture:list")
    @PostMapping("/list")
    public Result list(@RequestBody DanmoFamousPicture danmoFamousPicture)
    {
        startPage();
        List<DanmoFamousPicture> list = danmoFamousPictureService.selectDanmoFamousPictureList(danmoFamousPicture);
        return Result.success(getDataTable(list));
    }

    /**
     * 导出名帖字库图片列表
     */
//    @RequiresPermissions("system:picture:export")
    @Log(title = "名帖字库图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoFamousPicture danmoFamousPicture)
    {
        List<DanmoFamousPicture> list = danmoFamousPictureService.selectDanmoFamousPictureList(danmoFamousPicture);
        ExcelUtil<DanmoFamousPicture> util = new ExcelUtil<DanmoFamousPicture>(DanmoFamousPicture.class);
        util.exportExcel(response, list, "名帖字库图片数据");
    }

    /**
     * 获取名帖字库图片详细信息
     */
//    @RequiresPermissions("system:picture:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoFamousPictureService.selectDanmoFamousPictureById(id));
    }

    /**
     * 新增名帖字库图片
     */
//    @RequiresPermissions("system:picture:add")
    @Log(title = "名帖字库图片", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoFamousPicture danmoFamousPicture)
    {
        return toAjax(danmoFamousPictureService.insertDanmoFamousPicture(danmoFamousPicture));
    }

    /**
     * 修改名帖字库图片
     */
//    @RequiresPermissions("system:picture:edit")
    @Log(title = "名帖字库图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoFamousPicture danmoFamousPicture)
    {
        return toAjax(danmoFamousPictureService.updateDanmoFamousPicture(danmoFamousPicture));
    }

    /**
     * 删除名帖字库图片
     */
//    @RequiresPermissions("system:picture:remove")
    @Log(title = "名帖字库图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoFamousPictureService.deleteDanmoFamousPictureByIds(ids));
    }




}
